package com.neptune.websocket.client;

import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnBean(NettyWebSocketClient.class)
public class WebSocketClientConfigure {
    @Autowired(required = false)
    private NettyWebSocketClient nettyWebSocketClient;

    @Bean(name = "webSocketClient")
    public NettyWebSocketClient webSocketClient(){
        if(nettyWebSocketClient != null) {
            return nettyWebSocketClient;
        }
        throw new NoSuchBeanDefinitionException("没有找到合适的webSocketClient客户端Bean");
    }

}
